package asia.doing.common.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;



@Configuration
@EnableKnife4j
public class SwaggerConfig {

    @Bean
    public Docket createRestApi1() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("front")
                .select()
                .apis(RequestHandlerSelectors.basePackage("asia.doing.controller.front"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

    @Bean
    public Docket createRestApi2() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("manage")
                .select()
                .apis(RequestHandlerSelectors.basePackage("asia.doing.controller.manage"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

    @Bean
    public Docket createRestApi3() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("common")
                .select()
                .apis(RequestHandlerSelectors.basePackage("asia.doing.controller.common"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("BLOG's API")
                .description("博客管理API接口文档")
                .version("1.0")
                .build();
    }

}
